package wiki.xsx.core.snowflake.config.consul;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.cloud.consul.discovery.ConsulDiscoveryClient;
import org.springframework.cloud.consul.discovery.ConsulDiscoveryProperties;
import org.springframework.context.annotation.Configuration;
import wiki.xsx.core.snowflake.config.DiscoveryConfig;

/**
 * consul配置
 * @author xsx
 * @date 2019/11/20
 * @since 1.8
 */
@Configuration("snowflakeDiscoveryConfig")
@ConditionalOnClass({
        ConsulDiscoveryClient.class,
        ConsulDiscoveryProperties.class
})
public class ConsulDiscoveryConfig implements DiscoveryConfig {

    @Autowired
    private ConsulDiscoveryProperties properties;

    /**
     * 获取服务名称
     */
    @Override
    public String getServiceName() {
        return this.properties.getServiceName();
    }
}
